<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./code/chapter/18_http.js"></script>
</head>

<body>
    <textarea id="code">return "hi";</textarea>
    <button id="button">Run</button>
    <pre id="output"></pre>
    <script>
        document.querySelector("#button").addEventListener("click", () => {
            let code = document.querySelector("#code").value;
            let outputNode = document.querySelector("#output");
            try {
                let result = Function(code)();
                outputNode.innerText = String(result);
            } catch (e) {
                outputNode.innerText = "Error: " + e;
            }
        });
    </script>
</body>

</html>